package com.jeecms.pay.model;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class AbstractOrder {

	protected int id;

	/**
	 * 订单号
	 */
	protected String orderno;

	/**
	 * 平台用户id
	 */
	protected int userid;

	/**
	 * 用户账号
	 */
	protected String username;

	/**
	 * 创建时间
	 */
	protected Date createtime;

	/**
	 * 其它币值
	 */
	protected float otherMoney = 0;

	/**
	 * 平台币值
	 */
	protected float platformMoney;
	/**
	 * 交易前，剩余平台币值
	 */
	protected float beforeRemainMoney;
	/**
	 * 交易后，剩余平台币值
	 */
	protected float afterRemainMoney;

	/**
	 * 订单状态
	 */
	protected int status;

	/**
	 * 订单名称
	 */
	protected String orderName;

	/**
	 * 订单详细描述
	 */
	protected String desc;
	/**
	 * 买家联系方式
	 */
	protected String buyerPhone;
	/**
	 * 买家ip
	 * 
	 */
	protected String buyerIP;

	/**
	 * 扩展字段，原样传回
	 * 
	 */
	protected String extendColumn;

	/**
	 * 状态备注
	 * 
	 */
	protected String statusDesc;

	public enum Status {
		before {

			@Override
			public int getStatus() {
				return 0;
			}

		},
		success {

			@Override
			public int getStatus() {
				return 1;
			}

		},
		error {

			@Override
			public int getStatus() {
				return 2;
			}

		},
		mark_exchange {// 标记下，是否要兑换，该状态的订单是不需要被兑换的,因为可能支付时失败了

			@Override
			public int getStatus() {
				return 3;
			}

		},
		pay_success_and_to_be_exchange {// 支付成功了，则该兑换订单必须被用于兑换

			@Override
			public int getStatus() {
				return 4;
			}

		};

		public abstract int getStatus();
	}

	public String getStatusDesc() {
		return statusDesc;
	}

	public void setStatusDesc(String statusDesc) {
		this.statusDesc = statusDesc;
	}

	public String getExtendColumn() {
		return extendColumn;
	}

	public void setExtendColumn(String extendColumn) {
		this.extendColumn = extendColumn;
	}

	public String getBuyerIP() {
		return buyerIP;
	}

	public void setBuyerIP(String buyerIP) {
		this.buyerIP = buyerIP;
	}

	public String getBuyerPhone() {
		return buyerPhone;
	}

	public void setBuyerPhone(String buyerPhone) {
		this.buyerPhone = buyerPhone;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getOrderName() {
		return orderName;
	}

	public void setOrderName(String orderName) {
		this.orderName = orderName;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getOrderno() {
		return orderno;
	}

	public void setOrderno(String orderno) {
		this.orderno = orderno;
	}

	public int getUserid() {
		return userid;
	}

	public void setUserid(int userid) {
		this.userid = userid;
	}

	public Date getCreatetime() {
		return createtime;
	}

	public String getStrCreatetime() {
		String result = "";
		if (createtime != null) {
			result = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createtime);
		}
		return result;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	public float getPlatformMoney() {
		return this.platformMoney;
	}

	public String getStrPlatformMoney() {
		return new DecimalFormat("0.00").format(platformMoney);
	}
	
	public void setPlatformMoney(float platformMoney) {
		this.platformMoney = platformMoney;
	}

	public float getBeforeRemainMoney() {
		return beforeRemainMoney;
	}

	public void setBeforeRemainMoney(float beforeRemainMoney) {
		this.beforeRemainMoney = beforeRemainMoney;
	}

	public float getAfterRemainMoney() {
		return afterRemainMoney;
	}

	public void setAfterRemainMoney(float afterRemainMoney) {
		this.afterRemainMoney = afterRemainMoney;
	}

	public float getOtherMoney() {
		return otherMoney;
	}

	public void setOtherMoney(float otherMoney) {
		this.otherMoney = otherMoney;
	}

}
